/*YuO8szH0cVixePu/Bt+mG8nzASHeWTCVwWMjOHtSo769QXVx7+qWLr0JNVq8J5j3*/
import { ajax, toast } from 'nc-lightapp-front';
let searchId = 'query';
//点击查询，获取查询区数据
export default function clickSearchBtn(that) {
    let {
        schemeData
    } = that.state;
    let WholeVerifyData = that.props.ViewModel.getData('WholeVerifyDatas');
    //let searchDate = that.props.search.getAllSearchData(searchId);
    let queryInfo = that.props.search.getQueryInfo(searchId);
    getQueryInfoData(that,schemeData,queryInfo)
    let effectstatus = WholeVerifyData.effectstatus;
    let pagecode = that.props.getSearchParam('p');
    let verifyConditionVO = {
        objType: schemeData.objType.value,
        objTypeValue: schemeData.objTypeValue.value,
        pk_tradetype: schemeData.pk_tradetype.value,
        beginDate: schemeData.value[0],
        endDate: schemeData.value[1]
    }
    let data = {
        queryTreeFormatVO: that.props.search.getQueryInfo(searchId, true),
        verifyConditionVO: verifyConditionVO,
        pageId: pagecode,
        pk_bill: WholeVerifyData.pk_bill.value,
        pk_item: WholeVerifyData.pk_item,
        billType: WholeVerifyData.billType.value,
        ts: that.state.ts
    };
    let url = effectstatus == 0 ? '/nccloud/arap/billverify/preVerifyLinkingQuery.do' : '/nccloud/arap/billverify/nowVerifyQuery.do';
    ajax({
        url: url,
        data: data,
        success: (res) => {
            let {
                success,
                data
            } = res;
            if (success) {
                let {
                    settlement
                } = that.state;
                let datas = data.grid;
                that.state.ts = data.ts;
                that.this_sett = Number(data.this_sett).toFixed(data.scale);
                that.state.settlement.value = Number(0).toFixed(data.scale);//默认为0
                that.setState({
                    settlement
                });
                if (datas && datas[that.tableId]) {
                    toast({
                        color: 'success',
                        content:
                            that.state.json['verificationsheet-000126'] +
                            datas[that.tableId].rows.length +
                            that.state.json['verificationsheet-000127']
                    }); /* 国际化处理： 已成功共几条数据！*/
                    that.newTableData = datas[that.tableId];
                    that.props.editTable.setTableData(that.tableId, datas[that.tableId]);
                    that.props.button.setButtonDisabled(['VerifyLink','Share','NowVerify'], false);
                } else {
                    toast({
                        color: 'warning',
                        content: that.state.json['verificationsheet-000125']
                    }); /* 国际化处理： 未查询出相应的数据！*/
                    that.props.editTable.setTableData(that.tableId, {
                        rows: []
                    });
                    that.props.button.setButtonDisabled(['VerifyLink','Share','NowVerify'], true);
                }
            }
        }
    });
}
function getQueryInfoData(that,schemeData,queryInfo){
    let conditions = queryInfo.querycondition.conditions;
   // let { value ,schemeData} = that.state;
    let objtype = that.props.search.getSearchValByField( searchId, "objtype" );
    var obj =null;
    if (objtype&&objtype.value == 0) {
        obj = 'customer';
    } else if (objtype&&objtype.value == 1) {
        obj = 'supplier';
    } else if (objtype&&objtype.value == 2) {
        obj = 'pk_deptid';
    } else if (objtype&&objtype.value == 3) {
        obj = 'pk_psndoc';
    }
    if(conditions&&conditions.length>0){
        for(let i = 0 ;i<conditions.length;i++){
            if(conditions[i].field=='billdate'){
                schemeData.value[0] =conditions[i].value.firstvalue;
                schemeData.value[1]=conditions[i].value.secondvalue;
                
            }else if(conditions[i].field=='objtype'){
                schemeData.objType.value = conditions[i].value.firstvalue;
            }else if(conditions[i].field==obj){
                schemeData.objTypeValue.value =  conditions[i].value.firstvalue;
            }else if(conditions[i].field=='pk_tradetype'||conditions[i].field=='pk_tradetypeid'){
                schemeData.pk_tradetype.value =  conditions[i].value.firstvalue; //后台没支持多选交易类型，所以只能是一个
            }
        }
    }
}

/*YuO8szH0cVixePu/Bt+mG8nzASHeWTCVwWMjOHtSo769QXVx7+qWLr0JNVq8J5j3*/